/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MaterialPack;
import java.util.Vector;
import javax.microedition.lcdui.*;
import java.lang.String;
import Supporter.*;
/**
 *
 * @author Van persie
 */
public class CheckedButton extends Button {
    private Image unCheckIcon = null;
    private boolean isChecked = false;
    public CheckedButton(String normalTexture,String pressTexture,  String UnCheckTexture, int x,int y, int wid, int hei)
    {
        xPos = x;
        yPos = y;
        width = wid;
        height = hei;
        try{
            //Image temp = 
            ImageSupporter imgSpp = new ImageSupporter();
            normalIcon = ImageSupporter.transparent(imgSpp.getImage(normalTexture));
            
           // checkedIcon = ImageSupporter.transparent(imgSpp.getImage(checkedTexture));
            
            pressedIcon = ImageSupporter.transparent(imgSpp.getImage(pressTexture));
            
            unCheckIcon = ImageSupporter.transparent(imgSpp.getImage(UnCheckTexture));
            
            unCheckIcon = ImageSupporter.scaleImage(unCheckIcon, width, height);
            //text = txt;            
            isVisible = true;
            state = 0;
            //icon =  ImageSupporter.resizeImage(normalIcon, width, height);
            icon = ImageSupporter.scaleImage(normalIcon, width, height);
            //icon = normalIcon;
        }catch(Exception e)
        {
            isVisible = false;
        }
    }
    public CheckedButton(String normalTexture,String UnCheckTexture, int x,int y, int wid, int hei)
    {
        xPos = x;
        yPos = y;
        width = wid;
        height = hei;
        try{
            //Image temp = 
            ImageSupporter imgSpp = new ImageSupporter();
            normalIcon = ImageSupporter.transparent(imgSpp.getImage(normalTexture));
            
           // checkedIcon = ImageSupporter.transparent(imgSpp.getImage(checkedTexture));
            
            pressedIcon = ImageSupporter.transparent(normalIcon);
            
            unCheckIcon = ImageSupporter.transparent(imgSpp.getImage(UnCheckTexture));
            
            unCheckIcon = ImageSupporter.scaleImage(unCheckIcon, width, height);
            //text = txt;            
            isVisible = true;
            state = 0;
            //icon =  ImageSupporter.resizeImage(normalIcon, width, height);
            icon = ImageSupporter.scaleImage(normalIcon, width, height);
            //icon = normalIcon;
        }catch(Exception e)
        {
            isVisible = false;
        }
    }
    public boolean Release(int x, int y)
    {
        boolean temp = super.Release(x,y);
        if(temp)
            if(isChecked)
                isChecked = false;
            else
                isChecked = true;
        return  temp;
    }
        
    public void paint(Graphics g)
    {
        super.paint(g);
        if(isChecked)
            g.drawImage(unCheckIcon, getxPos(), getyPos(), Graphics.TOP | Graphics.HCENTER);
    }
    
}
